﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NYdlls;
namespace WeightCalc
{
    /// <summary>
    /// указываем сколько ложить чего и считем вес
    /// </summary>
    public class NY_Present : Present
    {
        private int SweetCount = 0,
                    ChocolateCount = 0,
                    CandyCount = 0,
                    LollipopCount = 0;
        public double counter;
        public NY_Present()
        {
            sweet = new List<Sweet>();
            choco = new List<Chocolate>();
            candy = new List<Candy>();
            lol = new List<Lollipop>();
            counter = 0.0;
        }
        public void setLollipops(int coin,double weight)
        {
            for (int i = 0; i < coin; i++)
            {
                lol.Add(new Lollipop());
                lol[LollipopCount].setWeight(weight);
                LollipopCount++;
            }
        }
        
        public void setChocolade(int coin, double weight,double per)
        {
            for (int i = 0; i < coin; i++)
            {
                choco.Add(new Chocolate(per));
                choco[ChocolateCount].setWeight(weight);
                ChocolateCount++;
            }
        }
        
        public void setSweet(int coin, double weight)
        {
            for (int i = 0; i < coin; i++)
            {
                sweet.Add(new Sweet());
                sweet[SweetCount].setWeight(weight);
                SweetCount++;
            }

        }
        
        public void setCandy(int coin, double weight)
        {
            for (int i = 0; i < coin; i++)
            {
                candy.Add(new Candy());
                candy[CandyCount].setWeight(weight);
                CandyCount++;
            }
        }
        public void setCandySets(int coin, double weight, string s1, string s2)
        {
            for (int i = 0; i < coin; i++)
            {
                candy.Add(new Candy());
                candy[CandyCount].setWeight(weight);
                candy[CandyCount].setFirm(s1);
                candy[CandyCount].setFilling(s2);
                CandyCount++;
            }
        }
        public void setSweetSets(int coin, double weight, string s1, string s2)
        {
            for (int i = 0; i < coin; i++)
            {
                sweet.Add(new Sweet());
                sweet[SweetCount].setWeight(weight);
                sweet[SweetCount].setColor(s1);
                sweet[SweetCount].setTaste(s2);
                SweetCount++;
            }

        }
        public void setChocoladeSets(int coin, double weight, double per)
        {
            for (int i = 0; i < coin; i++)
            {
                choco.Add(new Chocolate(per));
                choco[ChocolateCount].setWeight(weight);
                ChocolateCount++;
            }
        }
        public void setLollipopsSets(int coin, double weight, string s1)
        {
            for (int i = 0; i < coin; i++)
            {
                lol.Add(new Lollipop());
                lol[LollipopCount].setWeight(weight);
                lol[LollipopCount].setConsist(s1);
                LollipopCount++;
            }
        }
        //задаем кол-во и вес подарков
        public void Switcher(int ard, int col,int we)
        {
            switch (ard)
            {
                case 1://Sweet
                    this.setSweet(col, we);
                    break;
                case 2://Chocolade
                    this.setChocolade(col, we, 0.0);
                    break;
                case 3://Candy
                    this.setCandy(col, we);
                    break;
                case 4://lollipop
                    this.setLollipops(col, we);
                    break;
                default:
                    break;
            }

        }

        public double getWeight()
        {
            counter = 0;
            candy.ForEach(delegate(Candy c)
            {
                counter += c.getWeight();
            });
            sweet.ForEach(delegate(Sweet c)
            {
                counter += c.getWeight();
            });
            choco.ForEach(delegate(Chocolate c)
            {
                counter += c.getWeight();
            });
            lol.ForEach(delegate(Lollipop c)
            {
                counter += c.getWeight();
            });
            return counter;
        }
    }
}
